using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AssetCapture
{
    public partial class assetUpdateForm : Form
    {
        public delegate void AssetUpDate(string[] assetList);
        AssetUpDate aUpdate;
        private string[] List;


        public assetUpdateForm(string[] assetList, AssetUpDate listUpdate)
        {
            InitializeComponent();
            List = assetList;
            assetCheckListBox.CheckOnClick = true;
            assetCheckListBox.Items.AddRange(List);
            aUpdate = listUpdate;
        }

        private void assetCheckListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Unchecked)
            {
                if (assetCheckListBox.CheckedItems.Count == 1)
                    updateBotton.Enabled = false;
            }
            else
            {
                updateBotton.Enabled = true;
            }
        }


        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void updateBotton_Click(object sender, EventArgs e)
        {
            string[] assetNameList = new string[assetCheckListBox.CheckedItems.Count];

            for (int i = 0; i < assetCheckListBox.CheckedItems.Count; i++)
            {
                assetNameList[i] = (string)assetCheckListBox.CheckedItems[i];
            }
            aUpdate(assetNameList);
            this.Close();
        }


    }
}